---
title: "Bats and human blood project: median cell sizes"
output:
  html_document:
    df_print: paged
  pdf_document: default
---


# prepare
```{r}
pathWD.new <- "~/Documents/08_Pojekte/01_dRT-DC/220301_Bob_DataAnalysis_BatsHumans/20230925_SurfaceAreaToVolumeRatio"
setwd(pathWD.new)
```


# load data space image
```{r}
load(file.path(pathWD.new, "../20230829_AnimalTypeTempSexAnalysis", paste0("RDataSpace_v8", ".RData")))
```

# find meadian cell sizes and corresponding cells
```{r}
for (iter.AnimalType in levels.AnimalType) {
  print(paste0("Species = ", iter.AnimalType, ":"))
  tbl.AnimalType <- combTable[combTable$animalType == iter.AnimalType, ]
  medianArea <- median(tbl.AnimalType$area)
  print(paste0("Median cell size = ", medianArea, " um^2"))
  print("Cells:")
  tbl.medAreaCells <- tbl.AnimalType[tbl.AnimalType$area == medianArea, c("dateCode", "index","tempLevel","measNum","cellNum","area","velocity","tau1","tau2","deltaDefoTau1","deltaDefoTau2","eModulus","viscosity")]
  print(tbl.medAreaCells)
  write.csv(tbl.medAreaCells, file.path(pathWD.new, paste0("tbl", "_medianArea_", iter.AnimalType, ".csv")), row.names = FALSE)
  print("")
}
rm(tbl.AnimalType,medianArea)
```

